package behavioral.memento.historyonself;

import behavioral.memento.blackbox.IMemento;
import behavioral.memento.blackbox.Originator;

public class Main {

    public static void main(String[] args) {
        Originator originator = new Originator();
        originator.setState("running");
        System.out.println(originator.getState());
        IMemento memento = originator.createMemento();
        //memento.  这里没办法对备忘录对象做任何操作，保证了安全性
        originator.setState("stoping");
        System.out.println(originator.getState());
        originator.restoreMemento(memento);
        System.out.println(originator.getState());
    }
}
